package com.ysdwl.servlet;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysdwl.model.Provider;
import com.ysdwl.service.impl.ProviderService;

@WebServlet(urlPatterns = "/providerList")

public class ProviderListServlet extends HttpServlet{
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		try {
		ProviderService providerService = new ProviderService();
		List<Provider> list;

			list = providerService.findAll(null);
		
		
		req.setAttribute("list", list);
		
		req.getRequestDispatcher("providerList.jsp").forward(req, resp);
		
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException ,IOException {
		doGet(req, resp);
	};

}
